@extends('home.public.base')

@section('title', '商品详情')

@section('content')


    <div class="bg-f5f5f5 p-b-10">
        <div class="currentloc bg-f5f5f5 clear">
            <div class="center f12">
                <div class="fl"><a href="/">首页</a><span>/</span>{{$goods['title']}}</div>
                <a href="http://crm2.qq.com/page/portalpage/wpa.php?uin=779635593&cref=http://www.liwuyou.com/&ref=&f=1&ty=1&ap=&as="
                   class="fr qqbtn tc f-666" target="_blank">QQ在线交谈</a>

                <span class="fr m-r-100 f-a5937d"> </span>
            </div>
        </div>


        <div class="goods-info bg-fff overhide">
            <div class="center clear m-t-60">
                <div class="img-sm fl m-r-60" id="goods_img_list">
                    @foreach(explode('|',$goods['imgs']) as $limg)
                        <img src="/{{$limg}}">
                    @endforeach
                </div>
                <style>
                    #goods_single_list img{display: none}
                    #goods_single_list img:nth-of-type(1){display: block}
                </style>
                <div class="img-single fl rel" id="goods_single_list">
                    <span class="loading f16" style="display: none;">
                    </span>
                    @foreach(explode('|',$goods['imgs']) as $limg)
                        <img class="cloudzoom" src="/{{$limg}}">
                    @endforeach
                </div>

                <div class="goods-attr fr">
                    <h2 class="lh1 f30">{{$goods['title']}}</h2>
                    <h3 class="fn f14 m-t-20 f-666">
                        {{$goods['title']}}

                        <p style="color: red">
                            库存
                            <span class="stock" id="stock"> </span>
                            件
                        </p>
                    </h3>
                    <div class="clear m-t-20 price-box lh1">
                        <span class="fl f-d93732 f24 fb price-show" data-base-price="49.90"
                              data-discount="100">￥{{$goods['shop_price']}}</span>
                        <div class="p-y-20">
                            <div class="attr-box clear">
                                <span class="fl pro-title dib f-666">礼物款式：</span>
                                <span class="fl" id="selectstock">
	        		        	    @foreach($goodslists as $goodslist)
                                        <a href="javascript:void(0)" stock="{{$goodslist['stock']}}"
                                           goodsid="{{$goodslist['id']}}"
                                           class="select_attr  dib m-r-8 s_226">{{$goodslist['lists']}}</a>
                                    @endforeach
                                </span>
                            </div>
                        </div>
                        <div class="btn-box clear m-t-20 lh1">

                            <a href="javascript:void(0)" id="buy"
                               class="btn-red-single m-r-10 fl ani-bg ">购买</a>
                        </div>

                    </div>
                </div>
            </div>

            <script>
                $(function () {
                    $.ajaxSetup({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        }
                    });

                    //显示库存
                    $('#selectstock a').click(function () {
                        var stock = $(this).attr('stock');
                        $('#stock').text(stock);
                    });

                    //购买
                    $('#buy').click(function () {
                        var selectstock = $('#selectstock a.focus');
                        if (selectstock.length <= 0) {
                            alert('请选择规格');
                            return;
                        }

                        //组合数据 异步购买
                        //商品id
                        var id = "{{$goods['id']}}";
                        //商品名称
                        var name = "{{$goods['title']}}";
                        //商品规格
                        var lists = selectstock.text();

                        var data = {
                            id: id,
                            name: name,
                            lists: lists,
                            title: name
                        };

                        $.post("/addcart", data, function (result) {
                            //成功后 跳转购物车
                            if (result == 'ok') {
                                location.href = '/cart';
                            }
                        });
                    })

                })

            </script>
            <div class="detail-title bg-fff tc f18" id="detail_header">
                <div class="center rel">
                    <a href="javascript:void(0)" class="focus f-666" data-param="#discription">礼物详情</a>
                </div>
                <div class="detail-content bg-fff" id="discription">
                    {!! $goods['content'] !!}
                </div>
            </div>
            <script src="/home/js/base64.js"></script>
            <script src="/home/js/artdialog.js"></script>
            <script src="/home/js/goods.js"></script>
@endsection